#include<bits/stdc++.h>
using namespace std;
int t,d[100009],v[100009],a[100009],p[100009],h[100009];
struct lr{
    int ll,rr;
}xx[100009];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(int i=1;i<=t;i++){
        long long sum=0;
        int n,m,L,V;
        cin>>n>>m>>L>>V;
        for(int j=1;j<=n;j++) cin>>d[j]>>v[j]>>a[j];
        for(int j=1;j<=m;j++) cin>>p[j];
        for(int j=1;j<=n;j++){
            if(a[j]>=0){
                double st=sqrt(v[j]*v[j]*1.0+2.0*a[j]*d[j]);
                if(st>V) sum++,h[j]=1;
            }else{
                int pos=upper_bound(p+1,p+m+1,L)-p;
                pos-=1;
                double st=sqrt(v[j]*v[j]*1.0+2.0*a[j]*(d[j]-p[pos]));
                if(st>V) sum++,h[j]=1;
            }
        }
    cout<<sum<<" "<<m-1<<"\n";
        }
    return 0;
}
